package listbyorder.access001_100.test45;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/5/31 19:56
 */
public class Solution1 {

    public int jump(int[] nums) {
        if (nums == null || nums.length == 0) return 0;

        int ans = 0;
        int end = 0;
        int maxPosition = 0;
        for (int i = 0; i < nums.length - 1; i++) {
            maxPosition = Math.max(maxPosition, i + nums[i]);
            if (i == end) {
                end = maxPosition;
                ans++;
            }
        }
        return ans;
    }
}

